import http from 'http'
import zlip from 'zlib'
import fs from 'fs'
import process from 'process'
import path from 'path'

const cwd = process.cwd()

const gzip = zlip.createGzip()

const server = http.createServer((req, res) => {
    if (req.headers['accept-encoding']?.includes('gzip')) {
        console.log(req.headers);
    }

    console.log("-------------");
    




    res.writeHead(200, { "content-encoding": "gzip" })
    fs.createReadStream(path.join(cwd, 'src', '0010_解压缩', 'data.pdf')).pipe(gzip).pipe(res)
})

server.listen(3000)